package com.spzx.product.api;

import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.product.api.factory.RemoteProductServiceFallbackFactory;
import com.spzx.product.api.fallback.RemoteProductServiceFallback;
import com.spzx.product.api.vo.ProductSkuVo;
import com.spzx.product.api.vo.SkuPriceVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author XC
 * @version 1.0
 * @description
 * @knowledge
 */
@FeignClient(
        contextId = "remoteProductService",
        value = ServiceNameConstants.PRODUCT_SERVICE,
        // fallback = RemoteProductServiceFallback.class,  // 降级类
        fallbackFactory = RemoteProductServiceFallbackFactory.class  // 降级工厂类
)
public interface RemoteProductService {
    @Operation(summary = "获取商品 SKU详情")
    @GetMapping("/productSku/getProductSku/{skuId}")
    R<ProductSkuVo> getProductSku(
            @Parameter(description = "skuId")
            @PathVariable("skuId") Long skuId,

            @Parameter(description = "source")
            @RequestHeader(SecurityConstants.FROM_SOURCE) String source
    );

    @Operation(summary = "批量获取商品 SKU最新价格信息")
    @PostMapping(value = "/productSku/getSkuPriceList")
    R<List<SkuPriceVo>> getSkuPriceList(
            @RequestBody List<Long> skuIdList,
            @RequestHeader(SecurityConstants.FROM_SOURCE) String source
    );

    @Operation(summary = "获取商品 SKU最新价格信息")
    @GetMapping(value = "/productSku/getSkuPrice/{skuId}")
    R<SkuPriceVo> getSkuPrice(
            @PathVariable("skuId") Long skuId,
            @RequestHeader(SecurityConstants.FROM_SOURCE) String source
    );
}
